﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using Microsoft.SharePoint;

namespace FusionCharts.WebParts
{
    /// <summary>
    /// Contains several very useful and required methods used to generate charts.
    /// Most the methods are statics.
    /// </summary>
    class Utils
    {
        private static string[] DefaultColors = { "AFD8F8", "F6BD0F", "8BBA00", "FF8E46", "008E8E", "D64646", "8E468E", "588526", "B3AA00", "008ED6", "9D080D", "A186BE" };
        public static int DefaultHeight = 400;
        public static int DefaultWidth = 600;

        /// <summary>
        /// Generate a random number that will become the HTML ID of the chart
        /// </summary>
        /// <returns></returns>
        public static int GenerateRandomId()
        {
            Random random = new Random();
            return random.Next(0, 10000);
        }

        /// <summary>
        /// Returns the default colors in a string. Colors are separated by semi columns (;)
        /// </summary>
        /// <returns></returns>
        public static string GetDefaultColors()
        {
            StringBuilder sb = new StringBuilder();
            foreach (string color in DefaultColors)
            {
                sb.Append(color + ";");
            }
            // We return the string and remove the last semi column
            return sb.ToString().Substring(0, sb.Length-1);
        }
    }

    public enum GoogleChartType
    {
        PieChart
        , ColumnChart
        , LineChart
    }
    /// <summary>
    /// All Type of charts available
    /// </summary>
    public enum ChartType
    {
        FCF_Area2D,
        FCF_Bar2D,
        FCF_Candlestick,
        FCF_Column2D,
        FCF_Column3D,
        FCF_Doughnut2D,
        FCF_Funnel,
        FCF_Gantt,
        FCF_Line,
        FCF_MSArea2D,
        FCF_MSBar2D,
        FCF_MSColumn2D,
        FCF_MSColumn2DLineDY,
        FCF_MSColumn3D,
        FCF_MSColumn3DLineDY,
        FCF_MSLine,
        FCF_Pie2D,
        FCF_Pie3D,
        FCF_StackedArea2D,
        FCF_StackedBar2D,
        FCF_StackedColumn2D,
        FCF_StackedColumn3D
    };

    /// <summary>
    /// Restricted type of charts that can be used with SharePoint Lists
    /// </summary>
    public enum ChartTypeRestricted
    {
        FCF_Area2D,
        FCF_Bar2D,
        FCF_Column2D,
        FCF_Column3D,
        FCF_Doughnut2D,
        FCF_Funnel,
        FCF_Line,
        FCF_Pie2D,
        FCF_Pie3D
    }
}
